package testy;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.JTree;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
import javax.swing.border.TitledBorder;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import resources.UltimateOPS;
import cii_lib_graph.GAccessPanel;
import cii_lib_graph.GInterfaceTablePanel;
import cii_lib_graph.GInterfaceTerminal;

import com.cloudgarden.layout.AnchorConstraint;
import com.cloudgarden.layout.AnchorLayout;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class testFrame1 extends javax.swing.JFrame {
	
	private static final Logger log = LoggerFactory.getLogger(testFrame1.class);

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
		} catch(Exception e) {
			log.error("", e);
		}
	}


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel ciiFuncPanel;
	private JButton jButton2;
	private JTextField jTextField6;
	private JLabel jLabel4;
	private GAccessPanel gAccessPanel1;
	private GInterfaceTerminal gInterfaceTerminal1;
	private GInterfaceTablePanel gInterfaceTablePanel1;
	private JTextPane logPane1;
	private JScrollPane jScrollPane1;
	private JButton jButton8;
	private JTextField checkTextField11;
	private JButton jButton7;
	private JPanel jaccPanel1;
	private JLabel jLabel5;
	private JLabel jLabel3;
	private JLabel jLabel2;
	private JLabel jico1;
	private JTextField jTextField10;
	private JTextField jTextField9;
	private JTextField jTextField8;
	private JTextField jTextField7;
	private JTextField jTextField5;
	private JTextField jTextField4;
	private JTextField jTextField3;
	private JTextField jTextField2;
	private JTextField jTextField1;
	private JLabel jLabel1;
	private JLabel jLabelS;
	private JButton jButton9;
	private JPanel jPanel2;
	private JScrollPane jScrollPane2;
	private GInterfaceTerminal gInterfaceTerminal4;
	private JSeparator jSeparator2;
	private GInterfaceTerminal gInterfaceTerminal3;
	private JSeparator jSeparator1;
	private GInterfaceTerminal gInterfaceTerminal2;
	private JPanel jPanel1;
	private JScrollPane bitsScrollPane;
	private JButton jButton6;
	private JButton jButton5;
	private JButton jButton4;
	private JButton jButton3;
	private JButton jButton1;
	private JPanel testBsPanel;
	private JPanel ciiInPanel;
	private JTree jTree1;
	private JScrollPane jScrollPane3;
	private JPanel jPanel3;
	private JButton jButton10;

	private Icon gi = new ImageIcon("D:\\Aqua-Ball-Green-16x16.png");
	private Icon ri = new ImageIcon("D:\\Aqua-Ball-Red-16x16.png");

	private int randCount=0;
	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		testFrame1 inst = new testFrame1();
		inst.setVisible(true);
	}
	
	public testFrame1() {
		
		super();
		initGUI();
		
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				ciiFuncPanel = new JPanel();
				AnchorLayout ciiFuncPanelLayout = new AnchorLayout();
				getContentPane().add(ciiFuncPanel);
				ciiFuncPanel.setBounds(567, 406, 371, 364);
				ciiFuncPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0,0,0)), "CCII_IDENTIFICATOR", TitledBorder.LEADING, TitledBorder.TOP));
				ciiFuncPanel.setLayout(ciiFuncPanelLayout);
				{
					ciiInPanel = new JPanel();
					ciiFuncPanel.add(ciiInPanel, new AnchorConstraint(41, 990, 991, 9, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
					ciiInPanel.setBorder(BorderFactory.createTitledBorder(null, "COMP_ID", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog",1,12), new java.awt.Color(128,0,64)));
					ciiInPanel.setPreferredSize(new java.awt.Dimension(364, 399));
					ciiInPanel.setLayout(null);
					{
						testBsPanel = new JPanel();
						ciiInPanel.add(testBsPanel);
						testBsPanel.setBounds(14, 28, 336, 196);
						testBsPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(128,128,255)), "Check with hardware: ", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog",1,12), new java.awt.Color(46,101,184)));
						testBsPanel.setLayout(null);
						{
							jButton1 = new JButton();
							testBsPanel.add(jButton1);
							jButton1.setText("IDENTIFIER");
							jButton1.setBounds(25, 56, 105, 21);
							jButton1.setFont(new java.awt.Font("Tahoma",0,10));
						}
						{
							jButton2 = new JButton();
							testBsPanel.add(jButton2);
							jButton2.setText("NAME");
							jButton2.setFont(new java.awt.Font("Tahoma",0,10));
							jButton2.setBounds(25, 84, 105, 21);
							jButton2.addActionListener(new ActionListener() {
								public void actionPerformed(ActionEvent evt) {
									jLabel2.setEnabled(true);
									//TODO add your code for jButton2.actionPerformed
								}
							});
						}
						{
							jButton3 = new JButton();
							testBsPanel.add(jButton3);
							jButton3.setText("VERSION");
							jButton3.setFont(new java.awt.Font("Tahoma",0,10));
							jButton3.setBounds(25, 112, 105, 21);
							jButton3.addActionListener(new ActionListener() {
								public void actionPerformed(ActionEvent evt) {
									jLabel3.setIcon(ri);
									jLabel3.setEnabled(true);
									//TODO napisac funkce checkVersion();
								}
							});
						}
						{
							jButton4 = new JButton();
							testBsPanel.add(jButton4);
							jButton4.setText("USER");
							jButton4.setFont(new java.awt.Font("Tahoma",0,10));
							jButton4.setBounds(25, 140, 105, 21);
						}
						{
							jButton5 = new JButton();
							testBsPanel.add(jButton5);
							jButton5.setText("CREATOR");
							jButton5.setFont(new java.awt.Font("Tahoma",0,10));
							jButton5.setBounds(25, 168, 105, 21);
						}
						{
							jButton6 = new JButton();
							testBsPanel.add(jButton6);
							jButton6.setText("ALL");
							jButton6.setFont(new java.awt.Font("Tahoma",0,10));
							jButton6.setBounds(39, 28, 70, 21);
						}
						{
							jLabelS = new JLabel();
							testBsPanel.add(jLabelS);
							jLabelS.setText("Soft");
							jLabelS.setBounds(167, 28, 42, 21);
						}
						{
							jLabel1 = new JLabel();
							testBsPanel.add(jLabel1);
							jLabel1.setText("Hard");
							jLabel1.setBounds(263, 28, 42, 21);
						}
						{
							jTextField1 = new JTextField();
							testBsPanel.add(jTextField1);
							jTextField1.setText("0");
							jTextField1.setBounds(130, 56, 98, 21);
							jTextField1.setEditable(false);
							jTextField1.setColumns(2);
							jTextField1.setHorizontalAlignment(SwingConstants.CENTER);
						}
						{
							jTextField2 = new JTextField();
							testBsPanel.add(jTextField2);
							jTextField2.setColumns(2);
							jTextField2.setHorizontalAlignment(SwingConstants.CENTER);
							jTextField2.setText("0");
							jTextField2.setEditable(false);
							jTextField2.setBounds(228, 56, 98, 21);
						}
						{
							jTextField3 = new JTextField();
							testBsPanel.add(jTextField3);
							jTextField3.setColumns(2);
							jTextField3.setHorizontalAlignment(SwingConstants.CENTER);
							jTextField3.setText("0");
							jTextField3.setEditable(false);
							jTextField3.setBounds(130, 84, 98, 21);
						}
						{
							jTextField4 = new JTextField();
							testBsPanel.add(jTextField4);
							jTextField4.setColumns(2);
							jTextField4.setHorizontalAlignment(SwingConstants.CENTER);
							jTextField4.setText("0");
							jTextField4.setEditable(false);
							jTextField4.setBounds(228, 84, 98, 21);
						}
						{
							jTextField5 = new JTextField();
							testBsPanel.add(jTextField5);
							jTextField5.setColumns(2);
							jTextField5.setHorizontalAlignment(SwingConstants.CENTER);
							jTextField5.setText("0");
							jTextField5.setEditable(false);
							jTextField5.setBounds(130, 112, 98, 21);
						}
						{
							jTextField6 = new JTextField();
							testBsPanel.add(jTextField6);
							jTextField6.setColumns(2);
							jTextField6.setHorizontalAlignment(SwingConstants.CENTER);
							jTextField6.setText("0");
							jTextField6.setEditable(false);
							jTextField6.setBounds(228, 112, 98, 21);
						}
						{
							jTextField7 = new JTextField();
							testBsPanel.add(jTextField7);
							jTextField7.setColumns(2);
							jTextField7.setHorizontalAlignment(SwingConstants.CENTER);
							jTextField7.setText("0");
							jTextField7.setEditable(false);
							jTextField7.setBounds(130, 140, 98, 21);
						}
						{
							jTextField8 = new JTextField();
							testBsPanel.add(jTextField8);
							jTextField8.setColumns(2);
							jTextField8.setHorizontalAlignment(SwingConstants.CENTER);
							jTextField8.setText("0");
							jTextField8.setEditable(false);
							jTextField8.setBounds(228, 140, 98, 21);
						}
						{
							jTextField9 = new JTextField();
							testBsPanel.add(jTextField9);
							jTextField9.setColumns(2);
							jTextField9.setHorizontalAlignment(SwingConstants.CENTER);
							jTextField9.setText("0");
							jTextField9.setEditable(false);
							jTextField9.setBounds(130, 168, 98, 21);
						}
						{
							jTextField10 = new JTextField();
							testBsPanel.add(jTextField10);
							jTextField10.setColumns(2);
							jTextField10.setHorizontalAlignment(SwingConstants.CENTER);
							jTextField10.setText("0");
							jTextField10.setEditable(false);
							jTextField10.setBounds(228, 168, 98, 21);
						}
						{
							jico1 = new JLabel();
							testBsPanel.add(jico1);
							jico1.setIcon(gi);
							jico1.setBounds(6, 56, 21, 21);
							jico1.setEnabled(false);
						}
						{
							jLabel2 = new JLabel();
							testBsPanel.add(jLabel2);
							jLabel2.setIcon(gi);
							jLabel2.setEnabled(false);
							jLabel2.setBounds(6, 84, 21, 21);
						}
						{
							jLabel3 = new JLabel();
							testBsPanel.add(jLabel3);
							jLabel3.setIcon(gi);
							jLabel3.setEnabled(false);
							jLabel3.setBounds(6, 112, 21, 21);
						}
						{
							jLabel4 = new JLabel();
							testBsPanel.add(jLabel4);
							jLabel4.setIcon(gi);
							jLabel4.setEnabled(false);
							jLabel4.setBounds(6, 140, 21, 21);
						}
						{
							jLabel5 = new JLabel();
							testBsPanel.add(jLabel5);
							jLabel5.setIcon(gi);
							jLabel5.setEnabled(false);
							jLabel5.setBounds(6, 168, 21, 21);
						}
					}
					{
						jaccPanel1 = new JPanel();
						ciiInPanel.add(jaccPanel1);
						jaccPanel1.setBounds(14, 231, 336, 105);
						jaccPanel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(159,32,0)), "Check access: ", TitledBorder.LEADING, TitledBorder.TOP));
						jaccPanel1.setLayout(null);
						{
							jButton7 = new JButton();
							jaccPanel1.add(jButton7);
							jButton7.setText("Check with:");
							jButton7.setFont(new java.awt.Font("Tahoma",0,10));
							jButton7.setBounds(21, 21, 91, 21);
						}
						{
							checkTextField11 = new JTextField();
							jaccPanel1.add(checkTextField11);
							checkTextField11.setBounds(118, 21, 112, 21);
						}
						{
							jButton8 = new JButton();
							jaccPanel1.add(jButton8);
							jButton8.setText("Random");
							jButton8.setFont(new java.awt.Font("Tahoma",0,10));
							jButton8.setBounds(238, 21, 91, 21);
							jButton8.addActionListener(new ActionListener() {
								public void actionPerformed(ActionEvent evt) {
									JDialog howmanyD = new JDialog();
									JTextField samplesCount=null;
									howmanyD.setTitle("Samples");
									howmanyD.setLayout(null);
									{
										samplesCount = new JTextField();
										howmanyD.add(samplesCount);
										samplesCount.setText("how many?");
										final JTextField kpole = samplesCount;
										final JDialog tmp = howmanyD;
										samplesCount.addKeyListener(new KeyListener() {
										
											public void keyTyped(KeyEvent e) {
											    int len = kpole.getText().length();
											    
											    if (len < 9) {
											        return;
											        }
											      else {
											        	e.consume();
											           kpole.setCaretPosition(9);
											      }
											}
											public void keyReleased(KeyEvent e) {
											}										
											public void keyPressed(KeyEvent e) {
												char c = e.getKeyChar();
												if (c==KeyEvent.VK_ENTER) {
													try{
														randCount=new Integer(kpole.getText());
														logln("Samples count: "+randCount);
														tmp.dispose();
													} catch (NumberFormatException err) {
														kpole.setText("wrong !");
														kpole.selectAll();
													}
														return;
										         } else if (c==KeyEvent.VK_ESCAPE) {
										        	 tmp.dispose();
										        	 return;
										         }
											}										
										});
										samplesCount.selectAll();
										samplesCount.setBounds(7, 14, 70, 21);
									}
									{
										JButton jButtonD1 = new JButton();
										howmanyD.add(jButtonD1);
										jButtonD1.setText("Ok");
										final JDialog tmp = howmanyD;
										final JTextField tmpj = samplesCount;
										jButtonD1.addActionListener(new ActionListener() {
											public void actionPerformed(ActionEvent e) {
												try{
													randCount=new Integer(tmpj.getText());
													logln("Samples count: "+randCount);
													tmp.dispose();
												} catch (NumberFormatException err) {
													tmpj.setText("wrong !");
													tmpj.selectAll();
												}
											}
											
										});
										jButtonD1.setBounds(77, 14, 63, 21);
									}
									{
										JButton jButtonD2 = new JButton();
										howmanyD.add(jButtonD2);
										jButtonD2.setText("Cancel");
										final JDialog tmp = howmanyD;
										jButtonD2.addActionListener(new ActionListener() {
											public void actionPerformed(ActionEvent e) {
												tmp.dispose();
											}
										});
										jButtonD2.setBounds(35, 42, 77, 21);
									}
									howmanyD.setSize(155, 99);
								    howmanyD.setLocation(getMousePosition().x-100, getMousePosition().y-40);
									howmanyD.setVisible(true);
								}
							});
						}
						{
							jScrollPane1 = new JScrollPane();
							jaccPanel1.add(jScrollPane1);
							jScrollPane1.setBounds(21, 49, 308, 49);
							{
								logPane1 = new JTextPane();
								jScrollPane1.setViewportView(logPane1);
								logPane1.setEditable(false);
								logPane1.setFont(new java.awt.Font("Tahoma",0,10));
							}
						}
					}
				}
			}
			{
				gInterfaceTerminal1 = new GInterfaceTerminal();
				getContentPane().add(gInterfaceTerminal1);
				gInterfaceTerminal1.setToolTipText(UltimateOPS.getTESTToolTip());
				gInterfaceTerminal1.setBounds(63, 35, 554, 42);
			}
			{
				bitsScrollPane = new JScrollPane();
				getContentPane().add(bitsScrollPane);
				bitsScrollPane.setBounds(602, 112, 287, 238);
				{
					jPanel1 = new JPanel();
					BoxLayout jPanel1Layout = new BoxLayout(
						jPanel1,
						javax.swing.BoxLayout.Y_AXIS);
					jPanel1.setLayout(jPanel1Layout);
					bitsScrollPane.setViewportView(jPanel1);
					jPanel1.setPreferredSize(new java.awt.Dimension(462, 167));
					{
						gInterfaceTerminal2 = new GInterfaceTerminal();
						jPanel1.add(gInterfaceTerminal2);
					}
					{
						jSeparator1 = new JSeparator();
						jPanel1.add(jSeparator1);
					}
					{
						gInterfaceTerminal3 = new GInterfaceTerminal();
						jPanel1.add(gInterfaceTerminal3);
					}
					{
						jSeparator2 = new JSeparator();
						jPanel1.add(jSeparator2);
					}
					{
						gInterfaceTerminal4 = new GInterfaceTerminal();
						jPanel1.add(gInterfaceTerminal4);
					}
				}
			}
			{
				jScrollPane2 = new JScrollPane();
				getContentPane().add(jScrollPane2);
				jScrollPane2.setBounds(56, 91, 301, 28);
				{
					jPanel2 = new JPanel();
					BoxLayout jPanel2Layout = new BoxLayout(jPanel2, javax.swing.BoxLayout.X_AXIS);
					jPanel2.setLayout(jPanel2Layout);
					jScrollPane2.setViewportView(jPanel2);
					{
						jButton9 = new JButton();
						jPanel2.add(jButton9);
						jButton9.setText("jButton9");
						jButton9.setAlignmentX(Component.LEFT_ALIGNMENT);
						jButton9.setVisible(false);
					}
					{
						jButton10 = new JButton();
						jPanel2.add(jButton10);
						jButton10.setText("jButton10");
						jButton10.setAlignmentX(Component.LEFT_ALIGNMENT);
					}
				}
			}
			{
				jPanel3 = new JPanel();
				BorderLayout jPanel3Layout = new BorderLayout();
				jPanel3.setLayout(jPanel3Layout);
				getContentPane().add(jPanel3);
				jPanel3.setBounds(70, 224, 413, 238);
				{
					jScrollPane3 = new JScrollPane();
					jPanel3.add(jScrollPane3, BorderLayout.CENTER);
					{
						jTree1 = new JTree();
						jScrollPane3.setViewportView(jTree1);
					}
				}
			}
			{
				gAccessPanel1 = new GAccessPanel();
				getContentPane().add(gAccessPanel1.getJPanel());
				gAccessPanel1.setBounds(77, 42, 63, 28);
			}
			{
			
			}
			pack();
			this.setSize(1009, 575);
		} catch (Exception e) {
			log.error("", e);
		}
	}
	public JPanel getDefPane() {
		return jPanel3;
	}
	public JTree getTree() {
		return jTree1;
	}
	
	private void logln(String arg) {
		logPane1.selectAll();
		logPane1.setCaretPosition(logPane1.getSelectionEnd());
		logPane1.setEditable(true);
		logPane1.replaceSelection(arg+"\n");
		logPane1.setEditable(false);
	}

}
